import 'package:flutter/material.dart';
import 'package:get/get.dart';
import 'package:ljy_flutter/get/international/international_msg_controller.dart';

class InternationalizationExample extends StatelessWidget {
  InternationalizationExample({super.key});

  InternationalMsgController internationalMsgController = Get.put(InternationalMsgController());

  @override
  Widget build(BuildContext context) {
    return Scaffold(
      appBar: AppBar(
        title: const Text('GetX 国际化'),
      ),
      body: Center(
        child: Column(
          mainAxisAlignment: MainAxisAlignment.center,
          crossAxisAlignment: CrossAxisAlignment.center,
          children: [
            Text('hello'.tr, style: TextStyle(fontSize: 20, color: Colors.red),),
            SizedBox(height: 10,),
            Text('message'.tr, style: TextStyle(fontSize: 20, color: Colors.black),),
            SizedBox(height: 20,),
            ElevatedButton(onPressed: (){
              internationalMsgController.changeLanguage('zh', 'CN');
            }, child: Text('切换到中文')),
            SizedBox(height: 20,),
            ElevatedButton(onPressed: (){
              internationalMsgController.changeLanguage('en', 'US');
            }, child: Text('切换到English')),
            SizedBox(height: 20,),
            ElevatedButton(onPressed: (){
              internationalMsgController.changeLanguage('ja', 'JP');
            }, child: Text('切换到日本語')),
          ],
        ),
      ),
    );
  }
}